from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.by import By
from selenium.webdriver.chrome.options import Options
import time

# 设置 ChromeDriver 的路径
webdriver_service = Service('/path/to/chromedriver')

# 创建 Chrome 浏览器的选项对象
chrome_options = Options()
# chrome_options.add_argument("--headless")  # 无界面模式运行

# 创建 Chrome 浏览器对象
driver = webdriver.Chrome(service=webdriver_service, options=chrome_options)

# 访问网页
driver.get("https://console.sobot.com/imm/online/statistics/sessionRecord")

    



# 找到下载链接的元素
download_link = driver.find_element(By.XPATH, '//*[@id="root"]/div/div[2]/div/div/div/div/div[2]/div[1]/div[2]/div/div[2]/div/button/span')

# 点击下载链接
download_link.click()

# 等待下载完成
time.sleep(180)  # 根据实际情况调整等待时间

# 关闭浏览器
driver.quit()